import pymysql

def main():
    conn = pymysql.connect(host='47.110.246.28',port=3306,
                            user='jiadashuai',password='977911',
                            database='test1_db',charset='utf8')
    try:
        with conn.cursor() as cursor:
            result = cursor.execute(
                'insert into STUDENT values(1,"sunwukong",98)')
            if result == 1:
                print('添加成功')
            conn.commit()
    except pymysql.MySQLError as error:
        print('写入信息失败')
        conn.rollback()
    finally:
        conn.close()


if __name__=='__main__':
    main()